/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package controller;

import HibernateConfig.HibernateUtil;
import model.Paquete;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.Transaction;

/**
 *
 * @author Enrique
 */
public class PaqueteController {
    
    
    public static void guardarPaquete(Paquete paquete){
        
        Session sesion = HibernateUtil.getSessionFactory().openSession();
        Transaction transaccion = null;
        try {
            transaccion = sesion.beginTransaction();
            sesion.saveOrUpdate(paquete);
            transaccion.commit();
        
         // atrapo excepciones    
            } catch (HibernateException e){ 
                transaccion.rollback();
                e.printStackTrace();
            } finally {
                sesion.close(); // cierro la sesion (BD)
            }
    
    }
}
